What Is A Default Constructor ?
Default Constructor
1096
20-Jun-2018
Prakash nidhi Verma
20-Jun-2018Default Constructor :
If you are going to instantiate an array of objects of the class, the class must have a default constructor. If no user-defined constructor exists for a class A and one is needed, the compiler implicitly declares a default parameter less constructor A::A() .
Syntax:
class X {
public:
X(); // Default constructor with no arguments
X(int = 0); // Default constructor with one default argument
X(int, int , int = 0); // Constructor
};
Ex: